<template>
    <!--密码重置-->
    <AntdConfirmModal ref="pwdModalRef" title="密码重置" @confirm="handleConfirm">
        <a-form>
            <a-form-item label="新密码" name="password">
                <a-input v-model:value="password" placeholder="请输入新密码" maxlength="20" />
            </a-form-item>
        </a-form>

    </AntdConfirmModal>
</template>
<script setup>

import { resetPwd } from "@/module/system/api/user";
import useApp from '@/hooks';
const { $ } = useApp();
import emitter from '@/utils/mitt';
const pwdModalRef = ref(null);
const userId = ref(null);
const password = ref(null);
$.on('reset-pwd',e=>{
    userId.value = e;
    pwdModalRef.value.openModal()
});
// 执行确认
function handleConfirm(){
    resetPwd(userId.value, password.value).then(res=>{
        $.showToast({
            title:'密码重置成功',
            icon:'success'
        })
        pwdModalRef.value.closeModal()
    })
};
</script>